{% extends "base.html" %}
{% block title%}API列表{% endblock%}
{% block content %}
	<ol class="breadcrumb">
  		<li><a href="/autotester/projects">项目</a></li>
  		<li><a href="/autotester/project?id={{api.module.project.id}}">{{ api.module.project.name }}</a></li>
        <li><a href="/autotester/apis?mid={{api.module.id}}">{{ api.module.name }}</a></li>
  		<li class="active">{{ api.name }}</li>
	</ol>
	<div class="row">
		<form class="form-horizontal" role="form" method="POST" action="/autotester/api/update?id={{ api.id }}">
			{% csrf_token %}
			<div class="form-group">
    				<label for="name" class="col-sm-2 control-label">名称</label>
   				 <div class="col-sm-5">
      				<input type="text" name="name" class="form-control" id="name" value="{{api.name}}" placeholder="查询/创建/更新/删除 XXX">
   				 </div>
  			</div>
  			<div class="form-group">
    				<label for="url" class="col-sm-2 control-label">URL</label>
   				 <div class="col-sm-10">
      				<input type="text" name="url" class="form-control" id="url" value="{{api.url}}" placeholder="URL(例如：'/blog/query?n=1&s=10')">
   				 </div>
  			</div>
			<div class="form-group">
    				<label for="method" class="col-sm-2 control-label">请求方法</label>
   				 <div class="col-sm-10">
                    {% ifequal api.method "GET" %}
      				<label><input type="radio" name="method" value="GET" id="method" checked>GET</label>
					{% else %}
                    <label><input type="radio" name="method" value="GET" id="method" >GET</label>
                    {% endifequal %}
                    {%ifequal api.method "POST" %}
                    <label><input type="radio" name="method"  value="POST" checked>POST</label>
                    {% else %}
                    <label><input type="radio" name="method"  value="POST">POST</label>
                    {% endifequal %}
                    {%ifequal api.method "PUT"%}
					<label><input type="radio" name="method" value="PUT" checked>PUT</label>
                    {% else %}
                    <label><input type="radio" name="method"  value="PUT" >PUT</label>
                    {% endifequal %}
                    {%ifequal api.method "DELETE"%}
					<label><input type="radio" name="method" value="DELETE" checked>DELETE</label>
                    {% else %}
                    <label><input type="radio" name="method" value="DELETE">DELETE</label>
                    {% endifequal %}
   				 </div>
  			</div>
			<div class="form-group">
    				<label for="headers" class="col-sm-2 control-label">HEADERS</label>
   				 <div class="col-sm-10">
      				<textarea class="form-control" name="headers" id="headers" rows="10" placeholder='{"Content-Type":"application/json"}'>{{api.headers}}</textarea>
   				 </div>
  			</div>

    			<div class="form-group">
    				<div class="col-sm-offset-2 col-sm-10">
      			<button type="submit" class="btn btn-primary">保存</button>
    			</div>
  </div>
</form>
		
	</div>
{% endblock %}